package cn.com.hatech.cdkey.common.controller;

import cn.com.hatech.cdkey.common.exception.TipException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @projectName: hatech-blog
 * @package: cn.com.hatech.blog.common.controller
 * @className: GlobalExceptionHandler
 * @author: xuruikai
 * @description: 全局异常处理器
 * @date: 2020/1/11 14:27
 * @version: 1.0
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = TipException.class)
    public String tipException(Exception e) {
        log.error("find exception:e={}", e.getMessage());
        e.printStackTrace();
        return "comm/error_500";
    }


    @ExceptionHandler(value = Exception.class)
    public String exception(Exception e) {
        log.error("find exception:e={}", e.getMessage());
        e.printStackTrace();
        return "comm/error_404";
    }
}
